package com.ajobs.amqp.producer;

import com.ajobs.amqp.config.SampleExchangeRelConfig;
import com.ajobs.pojo.MsgPojo;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 *Description
 *
 *@author weijianxun
 */
@Component
public class SampleProducer {
    @Autowired
    private AmqpTemplate amqpTemplate;

    public void sendMsg(MsgPojo msgPojo) {
        // pojo需要实现序列化接口： org.springframework.amqp.support.converter.SimpleMessageConverter.createMessage
        amqpTemplate.convertAndSend(SampleExchangeRelConfig.EXCHANGE, SampleExchangeRelConfig.ROUTING_KEY, msgPojo);
    }
}
